<template>
  <div class="newsinfo-container">
    <h3 class="tittle">{{newsinfo.title}}</h3>
    <p class="info">
      <span>发表时间:{{newsinfo.time|dateFormat}}</span>
      <span>点击：{{id}}次</span>
    </p>
    <hr />
    <div class="content">
      <p>{{newsinfo.content}}{{newsinfo.content}}</p>
      <p>{{newsinfo.content}}{{newsinfo.content}}</p>
      <p>{{newsinfo.content}}{{newsinfo.content}}</p>
      <p>{{newsinfo.content}}{{newsinfo.content}}</p>
      <p>{{newsinfo.content}}{{newsinfo.content}}</p>
      <p>{{newsinfo.content}}{{newsinfo.content}}</p>

      <comment :newsid="id"></comment>
    </div>



    <!-- 评论组件 -->

  </div>
</template>

<script>

// 导入Comment子组件
import comment from "../subs-components/Comment.vue"
export default {
  data() {
    return {
      newsinfo: {}
    };
  },
  created() {
    console.log(this);
    this.getNewsInfo();
  },
  methods: {
    async getNewsInfo() {
      // 根据ID获取新闻的详情
      const { data } = await this.$http.get("/getBuildList?");
      if (data.status == 0) {
        console.log(data.data);
        this.newsinfo = data.data[5];
      }
    }
  },
  props: ["id"],
  components:{
    //为当前的NewsInfo.vue组件注册私有的子组件
    comment:comment
  }
};
</script>

<style scoped>
.newsinfo-container{
    padding: 3px;
}
.newsinfo-container .tittle {
  text-align: center;
  color: red;
}
.newsinfo-container .info {
    display: flex;
  color: rgb(38, 162, 255);
  justify-content:space-between;
}
</style>
    
